package com.client.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.client.pojo.User;
import com.client.service.Impl.UserServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "user-service", path = "/mall/users",fallback = UserServiceFallback.class)
public interface UserService {

    // 用户注册
    @PostMapping("/register")
    ResponseEntity<User> register(@RequestBody User user);

    // 用户登录
    @PostMapping("/login")
    ResponseEntity<User> login(@RequestParam("username") String username,
                               @RequestParam("password") String password);

    // 根据用户ID获取用户信息
    @GetMapping("/{userId}")
    ResponseEntity<User> getUserById(@PathVariable("userId") String userId);

    // 更新用户信息
    @PutMapping("/{userId}") // 这里需要指定路径
    ResponseEntity<User> updateUser(@RequestBody User user);

    // 删除用户
    @DeleteMapping("/{userId}")
    @ResponseStatus(HttpStatus.NO_CONTENT) // 明确表示成功删除时的状态码
    ResponseEntity<Void> deleteUser(@PathVariable("userId") String userId);

    // 获取所有用户列表（仅示例，实际可能需要权限控制等）
    @GetMapping
    ResponseEntity<List<User>> listAllUsers();
}
